home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Misc / Cookie / CookieV1.0 / cookie.filters / yow2cookie.c < prev   
Encoding:
C/C++ Source or Header  |  1995-06-12  |  692 b   |  33 lines

  1. #include <stdio.h>
  2.  
  3. /* format expected is leading comment followed by NULL ('\000'); then lots of cookies separated by NULLs; might as well strip out \n, 'cos they don't add anything */
  4. void main(int argc, char * argv[])
  5. {
  6.     int c;
  7.     char *title;
  8.     
  9.     if (argc < 2)
  10.         title = "Yow!";
  11.     else
  12.         title = argv[1];
  13.             
  14.     c = getchar();
  15.     while ((c != EOF) && (c != '\000')) {
  16.         /* skip initial comment */
  17.         c = getchar();
  18.     }
  19.     while (c != EOF) {
  20.         c = getchar();
  21.         printf("#%s%%", title);        /* cookie title */
  22.         while ((c != EOF) && (c != '\000')) {
  23.             /* write cookie */
  24.             if (c != '\n') {    /* strip returns */
  25.                 putchar(c);
  26.             }
  27.             c = getchar();
  28.         }
  29.         putchar('\n');
  30.     }
  31.     
  32.     printf("##\n");        /* end */
  33. }